package homework.morning;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class StringNum {
    public static void main(String[] args) {
        String str = "joasifaiojsf";
        Map<Character, Integer> a = new HashMap<>();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (a.containsKey(c)) {
                Integer value = a.get(c);
                value++;
                a.put(c, value);
            } else {
                a.put(c, 1);
            }
        }
        Set<Map.Entry<Character, Integer>> entrySet = a.entrySet();
        for (Map.Entry<Character, Integer> e : entrySet) {
            System.out.println("字母" + e.getKey() + "次数为：" + e.getValue());
        }

    }
}
